<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
<script src="http://libs.baidu.com/jquery/2.0.0/jquery.js"></script>
<link rel="stylesheet" href="/layui/css/layui.css">
<script src="/layui/layui.js"></script>
<style type="text/css">
.dc{
 	color: red;
 }
</style>
</head>
<body class="layui-layout-body"
	style="overflow-y: auto; overflow-x: hidden;">
	<form class="layui-form" style="padding: 10px 50px 10px 10px;">
		<div class="layui-form-item">
			<div class="layui-row">
				<div class="layui-col-sm12">
					<label class="layui-form-label">菜单编号<span class="dc"> * </span></label>
					<div class="layui-input-block">
						<input type="text" name="name" id="name" lay-verify="required"
							placeholder="菜单编号" autocomplete="off" class="layui-input"
							th:value="${serialNumber.msg}" readonly="readonly">
					</div>
				</div>
			</div>
		</div>

		<div class="layui-form-item">
			<div class="layui-col-sm12">
				<label class="layui-form-label">菜单名称<span class="dc"> * </span></label>
				<div class="layui-input-block">
					<input type="text" id="cname" lay-verify="required" placeholder="菜单名称" autocomplete="off" class="layui-input" value="">
				</div>
			</div>
		</div>

		<div class="layui-form-item">
			<div class="layui-col-sm12">
				<label class="layui-form-label">上一级编号<span class="dc"> * </span></label>
				<div class="layui-input-block">
					<input type="text" id="ctop" lay-verify="required" placeholder="上一级编号" autocomplete="off" class="layui-input" value="#" th:if="${handSn}==0" readonly="readonly">
					<input type="text" id="ctop" lay-verify="required" placeholder="上一级编号" autocomplete="off" class="layui-input" th:value="${handSn}" th:if="${handSn}!=0" readonly="readonly">
				</div>
			</div>
		</div>
		
		<div class="layui-form-item">
			<div class="layui-col-sm12">
				<label class="layui-form-label">所处层数<span class="dc"> * </span></label>
				 <div class="layui-input-block">
			        <input type="text" id="ctier" th:attr="name=${ctier}+1" th:if="${ctier}==0" class="layui-input" value="第1层" readonly="readonly">
			        <input type="text" id="ctier" th:attr="name=${ctier}+1" th:if="${ctier}==1" class="layui-input" value="第2层" readonly="readonly">
			        <input type="text" id="ctier" th:attr="name=${ctier}+1" th:if="${ctier}==2" class="layui-input" value="第3层" readonly="readonly">
			      </div>
			</div>
		</div>
		<div class="layui-form-item">
			<div class="layui-col-sm6">
				<label class="layui-form-label">是否上线<span class="dc"> * </span></label>
				<div class="layui-input-block">
					<select lay-filter="consignee" id="ispopup">
						<option value="">请选择状态</option>
						<option value="1">上线</option>
						<option value="0">不上线</option>
					</select>
				</div>
			</div>
		</div><br>
		<div class="layui-col-md12" style="text-align: center;">
			<span class="layui-btn layui-btn-normal" onclick="save();">确定</span>
			<button class="layui-btn layui-btn-primary" onclick="closeDialog();">取消</button>
		</div>
	</form>
	<script>
		layui
				.use(
						[ 'form', 'layedit', 'laydate' ],
						function() {
							var form = layui.form, layer = layui.layer, layedit = layui.layedit, laydate = layui.laydate;
						});
	</script>
	<script type="text/javascript">
		function num(obj){
			obj.value = obj.value.replace(/[^\d]/g,""); 
		}
		function save(){
			var params={};
			var cname = $("#cname").val()+'';
			let ctop = $("#ctop").val()+'';
			let ctier = $("#ctier").attr('name')+'';
			let ispopup = $("#ispopup").val();
			if($.trim(cname)===""){
	    		layer.msg("请输入菜单名称！", {icon: 5});
	    		return false;
	    	}
			if($.trim(ispopup)===''){
	    		layer.msg("请选择是否上线！", {icon: 5});
	    		return false;
	    	}
			params.cname = cname;
			params.ctop = ctop;
			params.ctier = ctier;
			params.ispopup = ispopup;
			$.ajax( {
		         url : '/admin/knowledge/addMenu6', 
		         type : 'post',
		         data: params,
		         dataType : 'json',
		         success : function(data) {
		        	 if(data.code==0){
		        		 layer.msg(data.msg,{icon: 1});
		        	 }else{
		        		 layer.msg(data.msg,{icon: 2});
		        	 }
		        	 setTimeout(function(){
		        		 location.reload();
					 },1500);
		         }
		     });
		}
		function closeDialog(){
			var index = parent.layer.getFrameIndex(window.name);
			parent.layer.close(index);
		}
	</script>


</body>
</html>